package logic

import (
	"activity_srv/activity"
	"activity_srv/internal/dao"
	"activity_srv/internal/svc"
	"context"
	"go.uber.org/zap"
	"smart-health-platforms/pkg"

	"github.com/zeromicro/go-zero/core/logx"
)

type SetDistributionLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewSetDistributionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SetDistributionLogic {
	return &SetDistributionLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 设置分销用户
func (l *SetDistributionLogic) SetDistribution(in *activity.SetDistributionRequest) (*activity.SetDistributionResponse, error) {
	//业务逻辑
	distribution, err := dao.SetDistribution(in)
	if err != nil {
		pkg.Error("设置分销规则失败", zap.Error(err))
		return nil, err
	}
	pkg.Info("设置分销规则成功", zap.Int64("id", distribution))
	return &activity.SetDistributionResponse{
		Id: distribution,
	}, nil
}
